const Service = require("egg").Service;

class CompanyService extends Service {


    //更新公司信息
    async update(cid, payload) {

        const company = await this.ctx.model.TCompanycnfo.findByPk(cid)
        if (!company) {
          this.ctx.throw(422, this.ctx.__("company not found"));
        }

        //上传的图片不等于已有的图片信息，删除旧图片
        if(company.Co_Logo!=payload.Co_Logo){
            await  this.ctx.helper.delFile(company.Co_Logo, this.config.baseDir)
        }
        await company.update(payload);
        return company;
    }



}

module.exports = CompanyService